//
//  PhotoInfoViewController.m
//  HeXun
//
//  Created by 8003 on 15/11/19.
//  Copyright © 2015年 LGC. All rights reserved.
//

#import "PhotoInfoViewController.h"
#import "GetXMLObject.h"
#import "NEWSModel.h"
#import "UIImageView+WebCache.h"
@interface PhotoInfoViewController ()
{
    NSArray* _imgArr;
    NSArray* _textArr;
}
@end

@implementation PhotoInfoViewController

- (void)viewDidLoad
{
    [super viewDidLoad];
    self.edgesForExtendedLayout &= ~UIRectEdgeTop|UIRectEdgeLeft;
    self.view.backgroundColor = [UIColor blackColor];
    self.ScrollView = [[UIScrollView alloc]initWithFrame:CGRectMake(0, 50, self.view.frame.size.width, self.view.frame.size.height-250)];
    [self.view addSubview:self.ScrollView];
    self.ScrollView.pagingEnabled = YES;
    self.ScrollView.contentOffset = CGPointMake(self.ScrollView.frame.size.width,0);
    self.ScrollView.delegate = self;
    GetXMLObject* xmlObject = [GetXMLObject new];
    
    _imgArr = [xmlObject getStrArrFrom:self.newsModel.matchpic using:@"|"];
    _ScrollView.contentSize = CGSizeMake(self.ScrollView.frame.size.width * _imgArr.count, self.ScrollView.frame.size.height);
    for (int i = 0; i < _imgArr.count; i++)
    {
        UIImageView* imageView = [[UIImageView alloc]initWithFrame:CGRectMake((self.ScrollView.frame.size.width) * i + 20, 50, self.ScrollView.frame.size.width-40, self.ScrollView.frame.size.height-100)];
        [imageView sd_setImageWithURL:[NSURL URLWithString:_imgArr[i]]];
        [self.ScrollView addSubview:imageView];
    }
    
    
    _textArr = [xmlObject getStrArrFrom:self.newsModel.content using:@"||"];
    self.textView.text = [NSString stringWithFormat:@"  1/%ld   %@",_textArr.count,_textArr[0]];
    
}

-(void)scrollViewDidScroll:(UIScrollView *)scrollView
{
   NSInteger i = scrollView.contentOffset.x / self.ScrollView.frame.size.width;
    self.textView.text = [NSString stringWithFormat:@"  %ld/%ld   %@",i+1,_textArr.count,_textArr[i]];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
